package seentao.stdev.mobile.init.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name="ts_version")
public class SystemVersion implements Serializable {
	
	private static final long serialVersionUID = 1L;

	/** 主键 */
	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	@Column(name = "id", length = 32)
	private String id;

	/**主版本号*/
	private Integer major;

	/**次版本号*/
	private Integer minor;
	
	/**修订版本号*/
	private Integer revision;
	
	/**修订版本日期*/
	@Column(length=8)
	private String revisionDate;
	
	/**
	 * 发版状态
	 * base: 基线
	 * dev: 开发版
	 * alpha: 内测版
	 * beta: 公测版
	 * rc: 发布候选版Release Candidate
	 * release: 发布版
	 */
	@Column(length=8)
	private String status;
	
	public SystemVersion(String ver) {
		String[] s1 = ver.split("_");
		String[] s2 = s1[0].split("\\.");
		this.major = new Integer(s2[0]);
		this.minor = new Integer(s2[1]);
		this.revision = new Integer(s2[2]);
		this.revisionDate = s2[3];
		this.status = s1[1];
	}
	
	public String toString() {
		return String.format("%s.%s.%s.%s_%s", major, minor, revision, revisionDate, status);
	}

}
